# -*- encoding : utf-8 -*-
class CreateUsers < ActiveRecord::Migration
  def change
    create_table :users do |t|
      t.string :username
      t.string :password
      t.string :salt
      t.string :email
      t.string :fullname
      t.string :card_id
      t.string :phone
      t.string :reader_id
      t.integer :faculty_id
      t.integer :role_id
      
      t.timestamps
    end
    
    add_index :users, :role_id
    add_index :users, :faculty_id
    
    add_foreign_key(:users, :roles, column: 'role_id')
    add_foreign_key(:users, :faculties, column: 'faculty_id')
  end
end
